import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        BankAccount act = new BankAccount();
        Scanner scan=new Scanner(System.in);
        int balance= scan.nextInt();
        act.setBalance(balance);
        int operation= scan.nextInt();
        for(int i=0;i<operation;i++)
        {
            char elect=scan.next().charAt(0);
            int money= scan.nextInt();
            if(elect=='w')
            {
                act.withdraw(money);
                System.out.println("balance: "+act.getBalance());
            }
            if(elect=='d')
            {
                act.deposit(money);
                System.out.println("balance: "+act.getBalance());
            }
        }
    }
}
class BankAccount{
    private int balance;

    public int getBalance() {
        return balance;
    }

    public void setBalance(int balance) {
        this.balance = balance;
    }

    public void BankAccount(){
        this.balance=0;
    }
    public void BankAccount(int money){
        this.balance=money;
    }
    public int getbalance(){
        return this.balance;
    }
    public void withdraw(int m){
        if(this.balance<m)
            System.out.print("Insufficient balance.");
        else
            this.balance-=m;
    }
    public void deposit(int m){
        this.balance+=m;
    }
}